import request from "../utils/request.js";

// 商品分类
const categorylist = '/api/goods_type/get_list';
// 购物车
const cartList = '/api/cart/get_list?'

// 积分商城
const pointType = '/api/product_type/get_list?'
// 获取全部积分商品
const allPointGoods = '/api/points_mall/get_list?'
// 点赞数量
const parse = '/api/praise/list_group?groupby=source_id&source_table=points_mall'
// 积分商城浏览状态
const status = '/api/hits/add?'
// 积分商品详情
const detail = '/api/points_mall/get_obj?points_mall_id='
// 某个商品的点赞数
const detailParse = '/api/praise/count?source_table=points_mall&source_field=points_mall_id&source_id='
// 我是否点赞
const isParse = '/api/praise/count?'

// 我是否收藏
const isCollect = '/api/collect/count?'

//评论列表
const commentList = '/api/comment/get_list?source_table=points_mall&source_field=points_mall_id&source_id='
// 收藏
const addCollect ='/api/collect/add?'
// 取消收藏
const deleteCollect ='/api/collect/del?'
// 点赞
const addParse ='/api/praise/add?'
// 取消点赞
const deleteParse ='/api/praise/del?'
// 设置点赞总数
const parse_len ='/api/points_mall/set?points_mall_id='
// 兑换商品
const pay ='/api/redeem_orders/add?'


// 商品分类
export function getCategorylist(data) {
	return request({
		url: categorylist,
		method: 'get',
		data
	})
}
export function getGoodsList(page, data) {
	return request({
		url: `/api/goods/get_list?like=0&page=${page}&size=12&orderby=hits%20desc`,
		method: 'get',
		data
	})
}

export function getGoodsType(page, type, data) {
	return request({
		url: `/api/goods/get_list?like=0&page=${page}&size=12&type=${type}&orderby=hits%20desc`,
		method: 'get',
		data
	})
}
export function getCartlist(data) {
	return request({
		url: cartList,
		method: 'get',
		data
	})
}
export function delCart(id, data) {
	return request({
		url: `/api/cart/del?cart_id=${id}`,
		method: 'get',
		data
	})
}

export function getType(data) {
	return request({
		url: pointType,
		method: 'get',
		data
	})
}
export function getGoods(data) {
	return request({
		url: allPointGoods,
		method: 'get',
		data
	})
}

export function getParse(data) {
	return request({
		url: parse,
		method: 'get',
		data
	})
}

export function hitBtn(id, data) {
	return request({
		url: `/api/points_mall/set?points_mall_id=${id}`,
		method: 'post',
		data
	})
}
export function add(data) {
	return request({
		url: status,
		method: 'post',
		data
	})
}

export function getDetail(id) {
	return request({
		url: detail + id,
		method: 'get',

	})
}
export function getDetailParse(id) {
	return request({
		url: detailParse + id,
		method: 'get',

	})
}

export function getIsParse(data) {
	return request({
		url: isParse,
		method: 'get',
		data
	})
}

export function getIsCollect(data) {
	return request({
		url: isCollect,
		method: 'get',
		data
	})
}

export function getComment(id) {
	return request({
		url: commentList + id,
		method: 'get',

	})
}

export function addCBtn(data) {
	return request({
		url: addCollect,
		method: 'post',
		data
	})
}
export function deleteCBtn(data) {
	return request({
		url: deleteCollect,
		method: 'get',
		data
	})
}
export function addPBtn(data) {
	return request({
		url: addParse,
		method: 'post',
		data
	})
}

export function deletePBtn(data) {
	return request({
		url: deleteParse,
		method: 'get',
		data
	})
}

export function setLen(id,data) {
	return request({
		url: parse_len+id,
		method: 'post',
		data
	})
}

export function payBtn(data) {
	return request({
		url: pay,
		method: 'post',
		data
	})
}
